package com.hrt.common.web;

import com.btcode.common.AbstractSingleton;
import com.btcode.json.IJsonConver;
import com.btcode.json.SqlClobAdapter;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import oracle.sql.CLOB;

public class JsonConver extends AbstractSingleton implements IJsonConver {

    private Gson gson;

    public JsonConver() {
        gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").registerTypeAdapter(
            CLOB.class, new SqlClobAdapter()).create();
    }

    public String toJson(Object data) {
        String json = gson.toJson(data);
        return json;
    }

}
